home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / misc1 / iv26_w30.zip / EXAMPLES / IDRAW / PAGE.H < prev    next >
C/C++ Source or Header  |  1980-01-05  |  4KB  |  119 lines

  1. /*
  2.  * Copyright (c) 1987, 1988, 1989 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software and its
  5.  * documentation for any purpose is hereby granted without fee, provided
  6.  * that the above copyright notice appear in all copies and that both that
  7.  * copyright notice and this permission notice appear in supporting
  8.  * documentation, and that the name of Stanford not be used in advertising or
  9.  * publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.  Stanford makes no representations about
  11.  * the suitability of this software for any purpose.  It is provided "as is"
  12.  * without express or implied warranty.
  13.  *
  14.  * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  19.  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  20.  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  21.  */
  22.  
  23. // $Header: page.h,v 1.5 90/01/25 16:27:26 interran Exp $
  24. // declares class Page.
  25.  
  26. #ifndef page_h
  27. #define page_h
  28.  
  29. #include <InterViews/Graphic/picture.h>
  30.  
  31. // Declare imported types.
  32.  
  33. class PictSelection;
  34.  
  35. // A Page draws a grid, picture, and boundary.  It can constrain
  36. // points to lie only on the grid.
  37.  
  38. static const int GRID_DEFAULTSPACING = 8;
  39.  
  40. class Page : public Picture {
  41. public:
  42.  
  43.     Page(double w, double h, double b, Graphic* = nil);
  44.     ~Page();
  45.  
  46.     Color* GetBackgroundColor();
  47.     boolean GetGridGravity();
  48.     double GetGridSpacing(boolean = false);
  49.     boolean GetGridVisibility();
  50.     PictSelection* GetPicture();
  51.  
  52.     void SetGridGravity(boolean);
  53.     void SetGridSpacing(double, boolean = false);
  54.     void SetGridVisibility(boolean);
  55.     void SetPicture(PictSelection*);
  56.  
  57.     void Center(float, float, float);
  58.     void Constrain(Coord&, Coord&);
  59.     void ToggleOrientation();
  60.  
  61. protected:
  62.  
  63.     void getExtent(float&, float&, float&, float&, float&, Graphic*);
  64.  
  65.     void draw(Canvas*, Graphic*);
  66.     void drawGrid(Canvas*, Graphic*);
  67.     void drawBoundary(Canvas*, Graphic*);
  68.  
  69.     void drawClipped(Canvas*, Coord, Coord, Coord, Coord, Graphic*);
  70.     void drawGridClipped(Canvas*, Coord, Coord, Coord, Coord, Graphic*);
  71.     void drawPictureClipped(Canvas*, Coord, Coord, Coord, Coord, Graphic*);
  72.     void drawBoundaryClipped(Canvas*, Coord, Coord, Coord, Coord, Graphic*);
  73.  
  74.     int DefinePoints(Coord, Coord, Coord, Coord, Graphic*);
  75.  
  76.     double pagewidth;        // stores exact width of page
  77.     double pageheight;        // stores exact height of page
  78.     int pgwidth;        // stores integral width of page
  79.     int pgheight;        // stores integral height of page
  80.     PBrush* border;        // stores brush for drawing boundary
  81.     boolean gravity;        // will constrain points to grid if true
  82.     boolean visibility;        // will draw grid points if true
  83.     double spacing_pixels;    // stores spacing in units of pixels
  84.     double spacing_points;    // stores spacing in units of printers' points
  85.     Coord* x, *y;        // stores grid points
  86.     Graphic* grid_gs;        // stores attributes for drawing grid/boundary
  87.     Transformer* grid_tt;    // stores matrix for drawing grid/boundary
  88.     PictSelection* picture;    // stores picture
  89.  
  90. };
  91.  
  92. // Define access functions to get and set members' values.
  93.  
  94. inline boolean Page::GetGridGravity () {
  95.     return gravity;
  96. }
  97.  
  98. inline double Page::GetGridSpacing (boolean in_pixels) {
  99.     return in_pixels ? spacing_pixels : spacing_points;
  100. }
  101.  
  102. inline boolean Page::GetGridVisibility () {
  103.     return visibility;
  104. }
  105.  
  106. inline PictSelection* Page::GetPicture () {
  107.     return picture;
  108. }
  109.  
  110. inline void Page::SetGridGravity (boolean g) {
  111.     gravity = g;
  112. }
  113.  
  114. inline void Page::SetGridVisibility (boolean v) {
  115.     visibility = v;
  116. }
  117.  
  118. #endif
  119.